package com.eipc;

import com.eipc.util.DBHelper;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

/**
 * 选手档案
 * @author x_liaolijun
 *
 * 2010-9-12 上午08:46:12
 *  
 * PlayerRecordActivity
 *
 */
public class SendMessageActivity extends CommonActivity {
	private ListView mListView;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.player_record);
		initView();
	}
	
	@Override
	protected void initView() {
		super.initView();
		mBar.setMiddleText(R.string.send_message); 
		if(mPerson!=null && mPerson.isLeader.equals(DBHelper.STATUS.LEADER_SMALL)){
			Intent i = new Intent(SendMessageActivity.this, SendMessageActivity2.class);
			i.putExtra("type", DBHelper.APP_TYPE_WORK_REPORT); 
			startActivityForResult(i,REQUEST_CODE_CHILD);
			this.finish();
		}else if(mPerson!=null && mPerson.isLeader.equals(DBHelper.STATUS.LEADER_HIGHT)){
			Intent i = new Intent(SendMessageActivity.this, SendMessageActivity2.class);
			i.putExtra("type", DBHelper.APP_TYPE_IMPORT_NOTICE); 
			startActivityForResult(i,REQUEST_CODE_CHILD);
			this.finish();
		}else{
			mListView = (ListView)findViewById(R.id.list1);
			mListView.setAdapter(new ArrayAdapter<String>(this, R.layout.simple_list_item_1, android.R.id.text1, mRe.getStringArray(R.array.send_message_type)));
			mListView.setOnItemClickListener(new OnItemClickListener() {
				@Override
				public void onItemClick(AdapterView<?> parent, View view,
						int position, long id) {
					Intent i = new Intent(SendMessageActivity.this, SendMessageActivity2.class);
					if(position==0){
						i.putExtra("type", DBHelper.APP_TYPE_IMPORT_NOTICE); 
					}
					else{
						i.putExtra("type", DBHelper.APP_TYPE_WORK_REPORT); 
					}
					startActivityForResult(i,REQUEST_CODE_CHILD);
				}
			});
		}
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if(requestCode == REQUEST_CODE_CHILD && resultCode == RESULT_CANCELED){
			finish();
		}
	}
}
